package com.yogee.topseller.utils;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.support.v4.content.ContextCompat;

import java.util.ArrayList;
import java.util.List;

/**
 * @auathor ${XiaoJianghong}
 * @date 2017/4/13.
 */

public class NeedPermissions {
    private Context context;
    private String[] needPermissions = { Manifest.permission.CAMERA,Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE};

    public NeedPermissions(Context context) {
        this.context = context;
    }

    /**
     * 相机所需权限
     *
     * @return
     */
    public List<String> cameraPermissions() {
      
        List<String> per = new ArrayList<>();
        for (int i = 0; i < needPermissions.length; i++) {
            if (ContextCompat.checkSelfPermission(context, needPermissions[i]) != PackageManager.PERMISSION_GRANTED) {
                per.add(needPermissions[i]);
            }
        }
        return per;
    }

    /**
     * 开启直播所需权限
     *
     * @return
     */
    public List<String> startLive() {
        String[] needPermissions = new String[]{
                Manifest.permission.CAMERA,
                Manifest.permission.READ_EXTERNAL_STORAGE,
                Manifest.permission.RECORD_AUDIO,
                Manifest.permission.WRITE_EXTERNAL_STORAGE
        };
        List<String> per = new ArrayList<>();
        for (int i = 0; i < needPermissions.length; i++) {
            if (ContextCompat.checkSelfPermission(context, needPermissions[i]) != PackageManager.PERMISSION_GRANTED) {
                per.add(needPermissions[i]);
            }
        }
        return per;
    }


}
